Watch events may get lost, the xenstored response races against the new
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 31 Oct 2005 16:07:14 +0000 (17:07 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 31 Oct 2005 16:07:14 +0000 (17:07 +0100)
watch being added to the watch list in register_xenbus_watch().  Fixed
by adding the watch to the list unconditionally, and remove it in the
error case.

linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c

index d55037177ba9ffccc0ebcccb5a9bf79b5256955c..55ba4b41ad51d68a4eaf5c18d1344f9ab07867ef 100644 (file)
@@ -682,14 +682,15 @@ int register_xenbus_watch(struct xenbus_watch *watch)
 
        spin_lock(&watches_lock);
        BUG_ON(find_watch(token));
+       list_add(&watch->list, &watches);
        spin_unlock(&watches_lock);
 
        err = xs_watch(watch->node, token);
 
        /* Ignore errors due to multiple registration. */
-       if ((err == 0) || (err == -EEXIST)) {
+       if ((err != 0) && (err != -EEXIST)) {
                spin_lock(&watches_lock);
-               list_add(&watch->list, &watches);
+               list_del(&watch->list);
                spin_unlock(&watches_lock);
        }